var isCheckAll = false;

function swapCheck() {
    if (isCheckAll) {
        $("input[type='checkbox']").each(function () {
            this.checked = false;
        });
        isCheckAll = false;
    } else {
        $("input[type='checkbox']").each(function () {
            this.checked = true;
        });
        isCheckAll = true;
    }
}

var t = null;
t = setTimeout(getTime,1000);
function getTime() {
    clearTimeout(t);
    var date = new Date();
    var year = date.getFullYear();
    var month = date.getMonth() + 1;
    var day = date.getDate();
    var hour = date.getHours();
    var minute = date.getMinutes();
    var second = date.getSeconds();
    if (day < 10) {
        day = "0" + day;
    }
    if (month < 10) {
        month = "0" + month;
    }
    if (hour < 10) {
        hour = "0" + hour;
    }
    if (minute < 10) {
        minute = "0" + minute;
    }
    if (second < 10) {
        second = "0" + second;
    }
    var time = year + "-" + month + "-" + day + "&nbsp;";
    time += hour + ":" + minute + ":" + second  + "&nbsp;";
    document.getElementById("manatime").innerHTML = time;
    setTimeout(getTime,1000);//每隔1000ms执行一次getTime()
}

//首页导航栏移动
function change() {
    if (document.getElementById("main-layout").classList.length === 1) {
        document.getElementById("main-layout").classList.add("hide-side");
    } else {
        document.getElementById("main-layout").classList.remove("hide-side");
    }
}

//首页遮罩事件
function removeClass() {
    document.getElementById("main-layout").classList.remove("hide-side");
}

//欢迎页获取前七天时间
function getBeforeDate(n) {
    var n = n;
    var d = new Date();
    var year = d.getFullYear();
    var mon = d.getMonth() + 1;
    var day = d.getDate();
    if (day <= n) {
        if (mon > 1) {
            mon = mon - 1;
        } else {
            year = year - 1;
            mon = 12;
        }
    }
    d.setDate(d.getDate() - n);
    year = d.getFullYear();
    mon = d.getMonth() + 1;
    day = d.getDate();
    return year + "-" + (mon < 10 ? ('0' + mon) : mon) + "-" + (day < 10 ? ('0' + day) : day);
}